package com.jian.service.impl;

import com.jian.dao.impl.UserDaoImpl;
import com.jian.pojo.User;
import com.jian.service.UserService;

import java.sql.SQLException;

/**
 * @author Jiange
 * @create 2021-04-06-20:57
 */
public class UserServiceImpl implements UserService {

    private UserDaoImpl userDao = new UserDaoImpl();

    @Override
    public void regiest(User user) throws SQLException {
        userDao.saveUsername(user);
    }

    @Override
    public User login(User user) throws Exception {
        return userDao.queryUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) throws SQLException {
        if(userDao.getUser(username) != null)
            return true;
        else return false;
    }
}
